<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Provisioning: Order #{orderDetailsBean.order.id} Details</title>
    </h:head>
    <h:body>
        <div style="text-align: center;">
            <h:panelGroup rendered="#{userSessionBean.loggedIn}" style="display:inline-block; width: 100%;">
                <h:panelGroup rendered="#{orderDetailsBean.order ne null and orderDetailsBean.order.userId eq userSessionBean.user.id}">
                    <p:panel header="Order Details" style="display: inline-block;">
                        <h:panelGrid columns="2" border ="1" style="text-align: left;">
                            <h:outputLabel value="Order ID:"/> <h:outputText value="#{orderDetailsBean.order.id}"/>
                            <h:outputLabel value="Order Date:"/> <h:outputText value="#{orderDetailsBean.order.orderDate}"/>
                            <h:outputLabel value="Provided:"/> <h:outputText value="#{orderDetailsBean.order.completionDate}"/>
                            <h:outputLabel value="Src. Router:"/> <h:outputText value="#{orderDetailsBean.order.sourceRouterName}"/>
                            <h:outputLabel value="Dst. Router:"/> <h:outputText value="#{orderDetailsBean.order.destinationRouterName}"/>
                            <h:outputLabel value="Bandwidth:"/> <h:outputText value="#{orderDetailsBean.order.bandwidth} kbit/s"/>
                            <h:outputLabel value="Status:"/> <h:outputText value="#{orderDetailsBean.order.status}"/>
                            <h:outputLabel value="Comment:"/> <h:outputText value="#{orderDetailsBean.order.comment}"/>
                        </h:panelGrid>
                        <h:link outcome="welcome" value="Return to Dashboard"/>
                    </p:panel>
                    <div><br /></div>
                    <p:panel header="Channel Information" style="display: inline-block;">
                        <h:form>
                            <p:dataTable var="link" value="#{orderDetailsBean.path}" paginator="true" rows="10" paginatorAlwaysVisible="false"
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                                         rowsPerPageTemplate="10,20,50">  
                                <p:column>  
                                    <f:facet name="header">  
                                        Link ID 
                                    </f:facet>  
                                    <h:outputText value="#{link.id}" />  
                                </p:column>

                                <p:column>  
                                    <f:facet name="header">  
                                        Link Title
                                    </f:facet>  
                                    <h:outputText value="#{link.title}" />  
                                </p:column>    

                                <p:column>  
                                    <f:facet name="header">  
                                        Total Bandwidth  
                                    </f:facet>  
                                    <h:outputText value="#{link.bandwidth} kbytes/s" />  
                                </p:column>  

                                <p:column>  
                                    <f:facet name="header">  
                                        Current Bandwidth 
                                    </f:facet>  
                                    <h:outputText value="#{link.currentBandwidth} kbytes/s" />  
                                </p:column>  

                                <p:column>  
                                    <f:facet name="header">  
                                        Router A / Router B
                                    </f:facet>  
                                    <div style="font-size: 14px;">
                                        [#{link.router1.id}]<h:commandLink action="#{routerExplorerBean.changeRouter(link.router1)}" value="#{link.router1.name}"/> /
                                        [#{link.router2.id}]<h:commandLink action="#{routerExplorerBean.changeRouter(link.router2)}" value="#{link.router2.name}"/>
                                    </div>
                                </p:column>  
                            </p:dataTable>
                        </h:form>
                    </p:panel>
                </h:panelGroup>
                <h:panelGroup rendered="#{orderDetailsBean.order eq null}">
                    <p:panel header="Order Details: Error" style="display: inline-block;">
                        You have to choose the order to display.
                        <h:link outcome="welcome" value="Return to Dashboard"/>
                    </p:panel>
                </h:panelGroup>
                <h:panelGroup rendered="#{orderDetailsBean.order.userId ne userSessionBean.user.id}">
                    <p:panel header="Order Details: Error" style="display: inline-block;">
                        Can not display the order with id = #{orderDetailsBean.order.id}: insufficient privileges.
                        <h:link outcome="welcome" value="Return to Dashboard"/>
                    </p:panel>
                </h:panelGroup>
            </h:panelGroup>
            <h:panelGroup rendered="#{!userSessionBean.loggedIn}">
                You are not logged in. Please, <h:link outcome="index" value="login"/>.
            </h:panelGroup>
        </div>
    </h:body>
</html>
